﻿@{
    Layout = "~/Views/Shared/OA/_Index.cshtml";
}
@section Toolbar
{
    @Html.MyNet().Button(new ButtonOptions { Text = "新建", Click = "create" })
    @Html.MyNet().Button(new ButtonOptions { Text = "删除", Click = "removee" })
}
@section Menu
{
    @Html.MyNet().Menu(new ButtonOptions { Text = "修改", Click = "modify" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "包含模块", Click = "module" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "包含配置", Click = "setting" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "包含角色", Click = "rolee" })
    @Html.MyNet().Menu(new ButtonOptions { Text = "删除", Click = "removee" })
}
@section Main
{
    <div id="grid" class="grid">
    </div>
    <div id="pager" class="pager">
    </div>
}
<script>

    var url = "/Common/Application/";
    var query = {};
    var pageSize = 20;
    var pageNo = 1;

    jQuery(function ()
    {
        read();
    });

    function read()
    {
        query.pageSize = pageSize;
        query.pageNo = pageNo;

        $.ajax
        ({
            url: url + "Read",
            data: query,
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                bind(result);
            }
        });
    }

    function create()
    {
        nav(url + "Create");
    }

    function modify()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Modify?Id=" + gridSelected()[0]);
    }

    function module()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Module?Id=" + gridSelected()[0]);
    }

    function rolee()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Role?Id=" + gridSelected()[0]);
    }

    function setting()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        nav(url + "Setting?Id=" + gridSelected()[0]);
    }

    function removee()
    {
        if (!gridSelected()) return alert("未选中任何数据！");
        if (!confirm("确定要删除选中的数据吗？")) return;

        $.ajax
        ({
            url: url + "Remove",
            data: { ids: gridSelected() },
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                read();
            }
        });
    }

</script>
